package com.tianhui.consignortwofei.other.auth.recognition.process;

import com.fgs.common.utils.ToastUtil;
import com.tianhui.consignortwofei.mvp.model.enty.BusinessLicenseInfo;
import com.tianhui.consignortwofei.mvp.model.enty.RecognitionInfo;
import com.tianhui.consignortwofei.mvp.model.enty.SelectPhotoInfo;
import com.tianhui.consignortwofei.mvp.model.enty.ocrResult.businessLicense.BusinessLicenseResult;
import com.tianhui.consignortwofei.other.auth.inte.ProcessCallback;
import com.tianhui.consignortwofei.other.auth.recognition.recognitionResultProcess.BusinessLicenseOcrResultProcess;

/**
 * @author fgs
 * @date 2021/6/25
 * @description
 **/
public class BusinessLicenseRecognitionProcess implements IRecognitionProcess<BusinessLicenseResult, BusinessLicenseInfo> {
    @Override
    public void recognitionProcess(RecognitionInfo<BusinessLicenseResult> recognitionInfo, SelectPhotoInfo selectPhotoInfo, ProcessCallback<BusinessLicenseInfo> processCallback) {
        String errorMessage = "不是营业执照或图片太模糊，请重新上传";
        BusinessLicenseResult result = recognitionInfo.info;
        if (result != null) {
            BusinessLicenseOcrResultProcess driverLicenseOcrResultProcess = new BusinessLicenseOcrResultProcess();
            BusinessLicenseInfo driverLicenseInfo = driverLicenseOcrResultProcess.getBusinessLicenseOcrResult(result);

//            if (TextUtils.isEmpty(driverLicenseInfo.name)) {
//                ToastUtil.showShortToast(errorMessage);
//                processCallback.processFailed();
//            } else {
            processCallback.processSuccess(driverLicenseInfo);
//            }

        } else {
            ToastUtil.showShortToast(errorMessage);
            processCallback.processFailed();
        }
    }
}
